package progeny;

public class Organism {
	
	public final Chromosome[] chromosomes;
	
	public Organism(){
		this(34);
	}
	
	public Organism(int numChrome){
		this(new Chromosome[numChrome]);
	}
	
	public Organism(Chromosome[] chromosomes){
		this.chromosomes = chromosomes;
	}
	
	public Organism mateWith(Organism other){
		Chromosome[] newZomes = new Chromosome[chromosomes.length];
		for (int i = 0; i < chromosomes.length; i++)
			newZomes[i] = Chromosome.getChromosome(this.chromosomes[i].getHalf(), other.chromosomes[i].getHalf());
		return new Organism(newZomes);
	}
	
	public Organism fuck(Organism other){
		return this.mateWith(other);
	}
	
	public boolean canMateWith(Organism other){
		return this.chromosomes.length == other.chromosomes.length;
	}
	
	public boolean canFuck(Organism other){
		return canMateWith(other);
	}
	
	public String getPhenotypes(){
		String result = "";
		for (Chromosome c: chromosomes) result+= c.getPhenotypes();
		return result;
	}
	
	public String toString(){
		String result = "";
		for (Chromosome c: chromosomes)result+=c.toString();
		return result.substring(0, result.length());
	}
}
